package cn.sc.allinpay.allfavour.base.model;

import cn.sc.allinpay.allfavour.app.AppWrapper;
import cn.sc.allinpay.allfavour.base.db.DbDao;
import cn.sc.allinpay.allfavour.business.common.app.Global;
import cn.sc.allinpay.allfavour.business.common.data.CheckCouponsRecord;
import cn.sc.allinpay.allfavour.business.common.data.TransRecord;

/**
 * description：
 * author：pany
 * on 2018/4/16 23:42
 */
public class BaseModel {

    public AppWrapper getAppWrapper() {
        return AppWrapper.getInstance();
    }

    public Global getGlobal() {
        return Global.getInstance();
    }

    public <T> DbDao<T> getDao(Class<T> cls) {
        return new DbDao<>(cls);
    }

    /**
     * 保存交易记录
     *
     * @param transRecord
     * @return
     */
    public int saveTransRecord(TransRecord transRecord) {
        DbDao<TransRecord> dbDao = getDao(TransRecord.class);
        return dbDao.add(transRecord);
    }

    /**
     * 修改交易记录
     *
     * @param transRecord
     * @return
     */
    public int updTransRecord(TransRecord transRecord) {
        DbDao<TransRecord> dbDao = getDao(TransRecord.class);
        return dbDao.update(transRecord);
    }


    /**
     * 保存验券记录
     *
     * @param checkRecord
     * @return
     */
    public int saveCheckRecord(CheckCouponsRecord checkRecord) {
        DbDao<CheckCouponsRecord> dbDao = getDao(CheckCouponsRecord.class);
        return dbDao.add(checkRecord);
    }
}
